package com.nkzy.service.impl;

import com.nkzy.domain.User;
import com.nkzy.mapper.UserMapper;
import com.nkzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Create by 王建烨 on 2022/3/11 10:05
 **/

@Service
public class UserServiceImpl implements UserService {
    // 依赖注入UserMapper 也可以用Resource
    @Autowired
    private UserMapper userMapper;

    /**
     * 查询所有用户
     *
     * @return List<User>
     */
    public List<User> findAll() {
        return userMapper.findAll();
    }

    /**
     * 查询一个用户
     *
     * @param id
     * @return User
     */
    public User findUserById(Integer id) {
        return userMapper.findUserById(id);
    }

    /**
     * 更新(删除、插入)用户
     *
     * @param user
     */
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    /**
     * 删除用户
     *
     * @param id
     */
    public void deleteUser(Integer id) {
        userMapper.deleteUser(id);
    }

    /**
     * 添加用户
     *
     * @param user
     */
    public void addUser(User user) {
        userMapper.addUser(user);
    }
}
